package raceReservationServer.raceServerGateway;

public class RaceServerGatewayFactory {

	/**
	 * ADD your code here; this class must be a SINGLETON String serviceUri =
	 * ip, port and name of the service String serverTech = technology of the
	 * server, 'corba' or 'ws'
	 */
	
	static private RaceServerGatewayFactory factoryInstance = null;
	
	private RaceServerGatewayFactory(){}
	
	static public RaceServerGatewayFactory getInstance()
	{
		if (factoryInstance == null)
		{
			factoryInstance = new RaceServerGatewayFactory();
		}
		return factoryInstance;
	}
	

	public IRaceServerGateway getRaceServerGateway(String serviceUri, String serverTechnology) {
		IRaceServerGateway the_gateway = null;
		
		if (serverTechnology.equals("corba"))
		{
			the_gateway = new CorbaRaceServerGateway(serviceUri) ;
		}
		else if (serverTechnology.equals("ws"))
		{
			the_gateway = new WSRaceServerGateway(serviceUri);
		} 
		else if (serverTechnology.equals("jms"))
		{
			the_gateway = new JMSRaceServerGateway(serviceUri);
		}
		return the_gateway;
	}
}
